<?php
namespace Modules\ShopAdmin\Http\Controllers;
use Illuminate\Http\Request;
use Modules\ShopAdmin\Models\ShopConfig as ShopConfigModel;
use Modules\Admin\Models\Image as ImageModel;
class ConfigController extends CommonShopController
{
	/**
	 * @name  配置页面
	 */
    public function index()
    {
		$info = ShopConfigModel::with('image_one')->find(1)->toArray();
		return view('shopadmin::config.index',compact('info'));
    }
	/**
	 * @name  编辑数据处理
	 */
    public function update(Request $request,$id)
    {
		$data = $request->all();
		if(isset($data['wallet_pay_status'])){
			$data['wallet_pay_status'] = 1;
		}else{
			$data['wallet_pay_status'] = 0;
		}
		if(isset($data['wechat_pay_status'])){
			$data['wechat_pay_status'] = 1;
		}else{
			$data['wechat_pay_status'] = 0;
		}
		$data = (new ImageModel())->edit_image('configs',$id,$data,'file');
		if(!is_array($data)){
			return $data;
		};
		return (new ShopConfigModel())->common_update($data,$id,route('shop_admin.config.index')); 
    }
	
	
	
	
	
	
	
	
}
